package com.itheima.exception;

import com.itheima.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice //用来捕获控制器Controller层的异常
public class GlobalHandlerException {
    @ExceptionHandler  //指定处理异常的类型
    public Result doException(Exception ex) {
        // 1.记录日志
        log.error("系统异常：{}", ex.getMessage());

        return Result.error("出错了请联系管理员");
    }
}
